Skip to content

Conversation

matheuspolitano
Copy link
Contributor

@matheuspolitano matheuspolitano commented Sep 16, 2025

Description

https://jira.schwarz/browse/STACKITCDN-875

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@matheuspolitano matheuspolitano requested a review from a team as a code owner September 16, 2025 09:46
@rubenhoenle
Copy link
Member

@matheuspolitano Could you please add a description to the PR which describes what you want to implement here?

@rubenhoenle rubenhoenle added has internal tracking issue needs-work PR needs changes by the author. labels Sep 16, 2025
@rubenhoenle
Copy link
Member

And I would kindly ask you to squash your commits into some meaningful ones. Having these 26 commits makes not much sense to me.

@rubenhoenle
Copy link
Member

On hold until #983 is merged.

@rubenhoenle
Copy link
Member

@matheuspolitano Could you please resolve the conflicts? :)

Comment on lines +741 to +753
// convertPointerSliceToStringSlice safely converts a slice of string pointers to a slice of strings.
func convertPointerSliceToStringSlice(pointerSlice []*string) []string {
if pointerSlice == nil {
return nil // Or []string{} depending on how you want to handle it
}
stringSlice := make([]string, 0, len(pointerSlice))
for _, strPtr := range pointerSlice {
if strPtr != nil { // Safely skip any nil pointers in the list
stringSlice = append(stringSlice, *strPtr)
}
}
return stringSlice
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to the utils package and add a few tests for this function? This is a function we probably need in some other places as well.

Comment on lines +637 to +639
oldCountriesPtrs := oldGeofencingMap[url]

oldCountries := convertPointerSliceToStringSlice(oldCountriesPtrs)
Copy link
Contributor

@marceljk marceljk Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be the case, that the old map might doesn't have the url, e.g. if someone extended the geofencing values via the api directly. So you need to check here, if the oldMap has the url key and if not, it must be handled correctly

geofencingCountry := make([]string, len(countryCodes))
for i, countryCodePtr := range countryCodes {
if countryCodePtr == nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an url has only one country code and this one is set to null, it will result in an api error, because the URL would have an empty array. So I would return here an error instead of continue

Comment on lines +431 to +436
countryStrings := make([]string, len(countries))
for i, countryPtr := range countries {
if countryPtr != nil {
countryStrings[i] = *countryPtr
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should return here an error, if coutryPtr is nil to prevent api issues. This could happen if someone sets null within the country list and then an empty array will be send to the api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has internal tracking issue needs-work PR needs changes by the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants